<template>
  <el-dropdown trigger="click" :class="className" @command="selectEvents">
    <span class="flex flex-js-c flex-ai-c cursor-pointer">
        <slot></slot>
    </span>
    <template #dropdown>
      <el-dropdown-menu>
        <template v-for="(item) in pullData">
          <el-dropdown-item :command="item">{{ item.title }}</el-dropdown-item>
        </template>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>
<script lang="ts">
/**
 * @param pullData 下拉数据字段
 *
 * @param className 定义类名
 */
import { defineComponent } from 'vue';
export default defineComponent({
  props: {
    pullData: {
      type: Array,
      default: ()=>{
        return []
      }
    },
    className: {
      type: String,
      default: ''
    }
  },
  emits: ["select"],
  setup(props, {emit}){
    const selectEvents = (item:any):void => {
      emit('select',item.code)
    }
    return {
      selectEvents
    }
  }
})
</script>
